# coding:utf-8

import time
import datetime

now = time.time()
print(now, type(now))  # 1658216435.025902 <class 'float'>

time_obj = time.localtime(now)
# time.struct_time(tm_year=2022, tm_mon=7, tm_mday=19, tm_hour=15, tm_min=40, tm_sec=35,
# tm_wday=1, tm_yday=200, tm_isdst=0) <class 'time.struct_time'>
print(time_obj, type(time_obj))

current_time_obj = time.localtime()
print(current_time_obj)

before = now - 100000
before_time_obj = time.localtime(before)
print(before_time_obj)

print(time.time() * 1000)  # 秒转成毫秒 1658216955335.218
print(time.time())  # 1658216955.335225

for i in range(10):
    print(i)
    # time.sleep(1)

datetime_now = datetime.datetime.now()
print(datetime_now)
datetime_timestamp = datetime.datetime.timestamp(datetime_now)
print('datetime生成的时间戳 %s' % datetime_timestamp)

datetime_obj = datetime.datetime.fromtimestamp(datetime_timestamp)
print(datetime_obj)
